package com.training.admin.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.demo2do.core.entity.page.Page;
import com.demo2do.core.persistence.annotation.Dao;
import com.training.admin.dao.TrainingResultDao;
import com.training.admin.entity.project.ProjectPhase;
import com.training.admin.entity.project.TrainingResult;
import com.training.admin.service.TrainingResultService;

/**
 * 
 * @author Rockett
 *
 */
@Service("trainingResultService")
public class TrainingResultServiceImpl extends DataServiceImpl<TrainingResult> implements TrainingResultService{
   
	@Dao
    private TrainingResultDao trainingResultDao;

	
  /*
   * (non-Javadoc)
   * @see com.training.admin.service.TrainingResultService#listByProjectPhaseId(java.lang.Long)
   */
	public List<TrainingResult> listByProjectPhaseId(Long projectPhaseId) {
		return trainingResultDao.listByProjectPhaseId(projectPhaseId);
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.training.admin.service.TrainingResultService#listByTraineeAndProjectPhase(java.lang.Long, java.lang.Long)
	 */
	public List<TrainingResult> listByTraineeAndProjectPhase(Long traineeId,Long projectPhaseId) {
		return trainingResultDao.listByTraineeAndProjectPhase(traineeId,projectPhaseId);
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.training.admin.service.TrainingResultService#listByTraineeAndProject(java.lang.Long, java.lang.Long)
	 */
	public List<TrainingResult> listByTraineeAndProject(Long traineeId,Long projectId) {
		return trainingResultDao.listByTraineeAndProject(traineeId,projectId);
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.training.admin.service.TrainingResultService#countByProject(java.lang.Long)
	 */
	public int countByProject(Long projectId) {
		return trainingResultDao.countByProject(projectId);
	}
	
    /* (non-Javadoc)
     * @see com.training.admin.service.TrainingResultService#listByProjectPhase(com.training.admin.entity.project.ProjectPhase, com.demo2do.core.entity.page.Page)
     */
    public List<TrainingResult> listByProjectPhase(ProjectPhase projectPhase, Page page) {
        List<TrainingResult> trainingResults = trainingResultDao.listByProjectPhase(projectPhase, page.getBeginIndex(), page.getMaxResultRecords());
        page.calculate();
        return trainingResults;
    }
    
    /* (non-Javadoc)
     * @see com.training.admin.service.TrainingResultService#count(com.training.admin.entity.project.ProjectPhase)
     */
    public int count(ProjectPhase projectPhase) {
        return trainingResultDao.countByProjectPhase(projectPhase);
    }

}
